import Vue from "vue";
import Design from "./design.vue";
import router from "./router";
import Antd from "ant-design-vue";
import AppConf from "@/config";
import store from "@/store/store";
import util from "@/libs/";
import "@/config/axiosConfig";
import * as filters from "@/filters";
import component from "@/components";
import vuescroll from "vuescroll";
import "vuescroll/dist/vuescroll.css";
import "@/styles/ant.css";
import "font-awesome/css/font-awesome.min.css";
import VueContextMenu from "vue-contextmenu";
import base from '@/libs/base'
base.setIco()
Vue.use(vuescroll);
Vue.use(VueContextMenu);
Vue.use(Antd);

Vue.use(require("vue-wechat-title"));
Vue.use(AppConf);

Vue.use(util);

Vue.use(component);
// 导入过滤器
Object.keys(filters).forEach(key => {
  Vue.filter(key, filters[key]);
});
/** 权限指令**/
Vue.directive("has", {
  inserted: function(el, binding) {
    const className = binding.value.class; // 这个地方要注意了，看下面页面上的代码，对应取得相应的值

    if (!Vue.prototype.$_has(className)) {
      el.parentNode.removeChild(el);
    }
  }
});
Vue.prototype.$_has = function(val) {
  let isShow = false;
  const btnPowerArr = sessionStorage.getItem("roleKeys");
  // console.log(btnPowerArr, 222);
  if (btnPowerArr === undefined || btnPowerArr === null) {
    return false;
  }
  if (btnPowerArr.indexOf(val) > -1) {
    isShow = true;
  }
  // console.log(isShow, 3333);
  return isShow;
};

function init() {
  if (!window.api.domain) {
    setTimeout(() => {
      init();
    }, 250);
    return;
  }
  new Vue({
    router,
    store,
    render: h => h(Design)
  }).$mount("#design");
}

init();
